package benny_driving_ser.util;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import javax.servlet.http.HttpSession;

public class CopiedIterator implements Iterator<HttpSession> {
	private Iterator<HttpSession> iterator = null;

	public CopiedIterator(Iterator<HttpSession> itr) {
		Set<HttpSession> list = new HashSet<HttpSession>();
		while (itr.hasNext()) {

			list.add((HttpSession) itr.next());
		}
		this.iterator = list.iterator();
	}

	public boolean hasNext() {
		return this.iterator.hasNext();
	}

	public void remove() {
		throw new UnsupportedOperationException("This is a read-only iterator");
	}

	public HttpSession next() {
		return this.iterator.next();
	}
}
